# -*- coding: utf-8 -*-
# @Time    : 2025/4/21 1:54
# @Author  : yxb
# @Email   : 18282090563@163.com
# @File    : class_page.py
# @Software: PyCharm
import unittest
from pages.base_page import BasePage
from appium.webdriver.common.appiumby import AppiumBy
from time import sleep

class ClassPage(BasePage):

    click_class_locator = (AppiumBy.ID,"com.xiachufang:id/tab_widget_content_classroom")

    click_class_search_locator = (AppiumBy.XPATH,'//android.widget.TextView[@text="想学点什么？"]')

    send_class_search_locator = (AppiumBy.XPATH,'//android.widget.EditText[@resource-id="com.xiachufang:id/search_edit_text"]')

    click_btn_search_locator = (AppiumBy.XPATH,'//android.widget.TextView[@text="搜索"]')



    click_qingjiaochaohaidai_locator = (AppiumBy.XPATH,'//android.view.View[@content-desc="青椒炒海带"]/android.view.View/android.view.View')

    click_collect_locator = (AppiumBy.XPATH,'//android.view.View[@content-desc="收藏"]')


    click_care_locator = (AppiumBy.XPATH,'//android.view.View[@content-desc="关注"]')



    click_video_locator = (AppiumBy.XPATH,'//android.view.View[@content-desc="会员免费 2693 人参与 菜男 武汉红油热干面专业技术解析与实操演示 8.9分"]/android.view.View/android.view.View')








    def click_class(self):
        self.find_element(self.click_class_locator).click()
        sleep(2)
    def click_search(self):
        self.find_element(self.click_class_search_locator).click()
        sleep(2)

    def input_search(self,meau):
        self.find_element(self.send_class_search_locator).send_keys(meau)
        sleep(2)


    # def send_search(self):
    #     self.find_element(self.click_class_search_locator).send_keys("菜谱")
    #     sleep(2)

    def click_btn_search(self):
        self.find_element(self.click_btn_search_locator).click()



    def click_qingjiaochaohaidai(self):
        self.find_element(self.click_qingjiaochaohaidai_locator).click()



    def click_collect(self):
        self.find_element(self.click_collect_locator).click()

    #点击第一个菜
    def click_first_menu(self):
        self.driver.tap([(500,500)],duration=None)
        sleep(2)
    #滑动
    def swipe(self):
        self.driver.swipe(550,1200,380,620,duration=3000)
        sleep(2)

    #点击关注
    def click_care(self):
        self.find_element(self.click_care_locator).click()
        sleep(2)









    def click_video(self):
        self.find_element(self.click_video_locator).click()
        sleep(2)
    def click_bofang(self):
        self.driver.tap([(300, 1735)], duration=None)
        sleep(2)

    def swipe_video(self):
        self.driver.swipe(76, 1810, 450, 1810, duration=2000)
        sleep(2)











